/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package SoftSonic;

import Rout.GoBefore;
import org.testng.annotations.*;
import org.openqa.selenium.Keys;

public class SoftsonicMain {

    private GoBefore browser = new GoBefore();

    @BeforeMethod
    public void setUp() throws Exception {

        System.out.println("\n Run test: " + getClass().getSimpleName());
        browser.setLpurl("getsecured");
//        browser.setRemoteDriver("192.168.4.85"); //Win7Clone VBox 

    }

    @Test
    public void ListButton() throws Exception {

        browser.setCurURL("http://softsonic.net/");
        browser.setClButton("");
        browser.setCssButton("body > div.main-container > div.content > div.main-content.left > div.items-list > ul > li:nth-child(7) > div.right > a");
        browser.setXpButton("/html/body/div[1]/div[2]/div[3]/div[2]/ul/li[2]/div[3]/a");
        browser.setXpFilename("/html/body/div[1]/div[2]/div[3]/div[2]/ul/li[2]/div[1]/a");
        browser.setRepDir(getClass().getSimpleName());
        browser.setUp();
        browser.testRun();
        browser.lpDetect();
        browser.verFilePresent();
        browser.verFilename();

    }

    @Test
    public void softPageUpbutton() throws Exception {
        browser.setCurURL("http://softsonic.net/happyland-adventures");
        browser.setClButton("");
        browser.setCssButton("#down-free");
        browser.setXpButton("//*[@id=\"down-free\"]");
        browser.setXpFilename("/html/body/div[1]/div[2]/div[2]/div[1]/h1/text()");
        browser.setRepDir(getClass().getSimpleName());

        browser.setUp();
        browser.testRun();
        browser.lpDetect();
        browser.verFilePresent();
        browser.verFilename();

    }

    @Test
    public void softPageDownbutton() throws Exception {
        browser.setCurURL("http://softsonic.net/happyland-adventures");
        browser.setClButton("");
        browser.setCssButton("body > div.main-container > div.content > div.product-content.left > div.product-info > div.product-feat.right > div.product-down.left > a");
        browser.setXpButton("/html/body/div[1]/div[2]/div[2]/div[2]/div[3]/div[2]/a");
        browser.setXpFilename("/html/body/div[1]/div[2]/div[2]/div[1]/h1/text()");
        browser.setRepDir(getClass().getSimpleName());
        browser.setUp();
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.testRun();
        browser.lpDetect();        
        browser.verFilePresent();
        browser.verFilename();

    }

    @Test
    public void upBar() throws Exception {
        browser.setCurURL("http://softsonic.net/happyland-adventures");
        browser.setClButton("");
        browser.setCssButton("");
        browser.setXpButton("//*[@id=\"product-fixed\"]/div/a");
        browser.setXpFilename("/html/body/div[1]/div[2]/div[2]/div[1]/h1/text()");
        browser.setRepDir(getClass().getSimpleName());

        browser.setUp();
        
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform(); 
        
        browser.testRun();
        browser.lpDetect();
        browser.verFilePresent();
        browser.verFilename();

    }
    
        @Test
    public void downLinks() throws Exception {
        browser.setCurURL("http://softsonic.net/happyland-adventures");
        browser.setClButton("");
        browser.setCssButton("body > div.main-container > div.content > div.product-content.left > div.similar-products > ul > li:nth-child(2) > div:nth-child(2) > a");
        browser.setXpButton("//html/body/div[1]/div[2]/div[2]/div[3]/ul/li[2]/div[2]/a");
        browser.setXpFilename("/html/body/div[1]/div[2]/div[2]/div[3]/ul/li[2]/div[1]/a");
        browser.setRepDir(getClass().getSimpleName());

        browser.setUp();
        
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform(); 
        
        browser.testRun();
        browser.lpDetect();
        browser.verFilePresent();
        browser.verFilename();

    }

    @AfterMethod
    public void ThearsDown() {
        browser.getDriver().quit();

    }

}
